﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CRMWeb.Pages.AM
{
    public partial class EditBankDetails : CRMWeb.Utilities.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            btnChngStsE.Visible = false;
        }

        protected void btnEdit_Click(object sender, EventArgs e)
        {

            string digitalKey = WebConfigurationManager.AppSettings["EziDebitDigitalKey"].ToString();
            var crRef = txtCusRefE.Text;
            if (digitalKey != null & crRef != null)
            {
                StringBuilder sb = new StringBuilder();
                //Edit bank details for payment
                sb.Append("<script language='javascript'>window.open('https://widget.demo.ezidebit.com.au/account/Edit?dk=" + digitalKey + "&er="+crRef+"', 'List', 'left = 300,top=150,scrollbars=no, resizable=no,width=500,height=450');</script>");

               
                if (!Page.ClientScript.IsClientScriptBlockRegistered(Page.GetType(), "HeyPopup"))
                    ClientScript.RegisterClientScriptBlock(Page.GetType(), "HeyPopup", sb.ToString());

            }
            ClearAll();
            btnEdit.Visible = false;
            btnChngStsE.Visible = true;
            btnChngStsE.Text = "Add Payment";
        }

        protected void btnChngStsE_Click(object sender, EventArgs e)
        {
            var crRef = txtCusRefE.Text;
            Response.Redirect("AddPaymentEziDebit.aspx?CId="+crRef);
        }

        //Method to clear all fields
        public void ClearAll()
        {
            
            txtCusRefE.Text = "";
        }

       


        
    }



}